package com.zm.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author TaoYuan
 * @version V1.0.0
 * @date 2018/4/19 0019
 * @description description
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket buildDocket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(buildApiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.zm.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo buildApiInfo() {
        return new ApiInfoBuilder()
                .title("吊炸天的 restfulAPI")
                .description("基于springboot swagger2的吊炸天的 restfulAPI")
                .termsOfServiceUrl("https://blog.csdn.net/lftaoyuan")
                .contact(new Contact(
                        "zcx",
                        "https://www.demo.cc",
                        "demo@qq.com"))
                .version("1.0")
                .build();
    }


}

